﻿<Window x:Class="RemResTestClient.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
        xmlns:command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"
        xmlns:viewModel="clr-namespace:RemResTestClient.ViewModel"
        Title="RemRes Test Client" Height="700" Width="900">
    <Window.Resources>
        <viewModel:MainViewModel x:Key="mainViewModel" />
    </Window.Resources>
    <Grid DataContext="{StaticResource mainViewModel}" x:Name="mainGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" HorizontalAlignment="Stretch" Margin="0,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Margin="10,0">Client:</TextBlock>
            <TextBox Grid.Column="1" Text="{Binding ClientAddress,Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
                     Margin="0,0,10,0"></TextBox>
        </Grid>

        <Grid Grid.Row="1" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <TextBlock Margin="10,10,10,5">Message:</TextBlock>

            <ComboBox Grid.Column="1" Margin="0,3,10,3"
                      ItemsSource="{Binding MessageTypes}"
                      SelectedItem="{Binding SelectedMessageType}" >
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding MessageName}"></TextBlock>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
        </Grid>
        
        <TextBox x:Name="txtInputMessage" Grid.Row="2" AcceptsReturn="True" FontFamily="Courier New"  
                 Text="{Binding UserMessageInput, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ScrollViewer.CanContentScroll="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" AcceptsTab="True" >
        </TextBox>
        <TextBlock Grid.Row="3" Margin="10,10,10,5" >Response:</TextBlock>
        <TextBox x:Name="txtOutputMessage" Grid.Row="4" AcceptsReturn="True" IsReadOnly="True" Background="LightGray" 
                 ScrollViewer.CanContentScroll="True" AcceptsTab="True" VerticalScrollBarVisibility="Auto" 
                 HorizontalScrollBarVisibility="Auto" 
                 Text="{Binding ResponseMessage}"/>

        <Grid Grid.Row="5" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column="0" Orientation="Horizontal">
                <!--<Button Margin="10" Command="{Binding MessageSend}" >Validate Message</Button>-->
                <Button Margin="10" Command="{Binding MessageSend}" >Send Message</Button>
            </StackPanel>
            <StackPanel Grid.Column="1" Orientation="Vertical" VerticalAlignment="Center">
                <TextBlock>Notification Endpoint:</TextBlock>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="[IP/localhost]:" FontWeight="Bold"></TextBlock>
                    <TextBlock Text="{Binding NotificationPort}" FontWeight="Bold" ></TextBlock>
                </StackPanel>
            </StackPanel>
            <TextBlock Margin="10,0,0,0" Grid.Column="2" TextWrapping="Wrap" TextTrimming="WordEllipsis" VerticalAlignment="Center"
                       Foreground="PaleVioletRed" Text="{Binding ErrorMessage}" />
        </Grid>
    </Grid>
</Window>
